<html>
<head><meta charset="utf-8"><title>concurrent read / write with async fn in traits · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html">concurrent read / write with async fn in traits</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="240646929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/240646929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Carl Lerche <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#240646929">(May 28 2021 at 18:59)</a>:</h4>
<p>This is my first attempt at creating a topic, I thought I would break out from "inline" async fn in traits where concurrently reading from AsyncRead + AsyncWrite was being discussed.</p>



<a name="240646981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/240646981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Carl Lerche <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#240646981">(May 28 2021 at 18:59)</a>:</h4>
<p>Here is a trait proposal that would support concurrent reads + writes w/o lang changes (besides async fn in trait): <a href="https://gist.github.com/carllerche/5d7037bd55dac1cb72891529a4ff1540">https://gist.github.com/carllerche/5d7037bd55dac1cb72891529a4ff1540</a></p>



<a name="240648153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/240648153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#240648153">(May 28 2021 at 19:09)</a>:</h4>
<p>I'm not sure if this still belongs to the other discussion or not (but that's fair - it's a separate thread). The other thread one was about  primarily "how to make native async traits", and solve <code>AsyncRead/Write</code> as one concrete problem. </p>
<p>Your gist seems to be about just having another non async native version of those. Do you think this is worthwhile a discussion at all? I think the "workaround traits" have been discussed in enough other places (e..g. when tokio moved to another version of them, the discussions in futures-rs, etc). Any kind of non native async trait will not allow composition via async methods (e.g build a wrapper around <code>AsyncRead</code> which delays reading for some time by calling <code>sleep(time).await</code>, which currently makes those things hard to use for non-experts.</p>



<a name="240649747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/240649747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Carl Lerche <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#240649747">(May 28 2021 at 19:24)</a>:</h4>
<p>"Do you think this is worthwhile a discussion at all? " is not a productive comment. This proposal is different than any other and it is possible to integrate any wrapper that adds delays by adding the delay in the <code>ready()</code> fn and not succeeding the read until the delay elapses.</p>



<a name="240655502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/240655502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Carl Lerche <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#240655502">(May 28 2021 at 20:15)</a>:</h4>
<p>I realize the confusion, I forgot to add <code>async</code> on <code>async fn ready</code>, sorry</p>



<a name="241156084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/241156084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#241156084">(Jun 02 2021 at 14:25)</a>:</h4>
<p>Catching up</p>



<a name="241156093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/241156093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#241156093">(Jun 02 2021 at 14:25)</a>:</h4>
<p>Sorry <span class="user-mention" data-user-id="224941">@Carl Lerche</span> for being slow</p>



<a name="241156223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/241156223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#241156223">(Jun 02 2021 at 14:26)</a>:</h4>
<p>I agree that it's worth exploring-- I still feel like we're in a kind of brainstorming phase</p>



<a name="241156292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/241156292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#241156292">(Jun 02 2021 at 14:27)</a>:</h4>
<p>this interface seems pretty reasonable to me, and easy enough to "package up" with read and write methods</p>



<a name="241156348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/241156348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#241156348">(Jun 02 2021 at 14:27)</a>:</h4>
<p>that are basically convenience wrappers that iterate around "ready" and "try" calls</p>



<a name="241156462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/241156462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#241156462">(Jun 02 2021 at 14:28)</a>:</h4>
<p>it seems clear that this interface doesn't work for io-uring, and that we want another one for that, one that is more "transferring buffer oriented"-- I'm wondering if that's just generally true</p>



<a name="241156516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/concurrent%20read%20/%20write%20with%20async%20fn%20in%20traits/near/241156516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/concurrent.20read.20.2F.20write.20with.20async.20fn.20in.20traits.html#241156516">(Jun 02 2021 at 14:28)</a>:</h4>
<p>that is to say: the current async read/write traits also seem pretty tied to the "epoll/readiness"-style of unix read/write functions</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>